<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>抓取航线设置-新增</title>
<%-- <script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/show.js"></script> --%>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/common.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/multiblepicker.js"></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<link
	href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
	<link href="<%=request.getContextPath()%>/fare/css/base.css" rel="stylesheet" type="text/css" />
<link
	href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/ligerui-icons.css"
	rel="stylesheet" type="text/css" />
<link href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css' rel="stylesheet" type="text/css" />
<link rev="stylesheet" media="all" href="<%=request.getContextPath() %>/fare/css/form_style.css" type="text/css" rel="stylesheet">
<!-- 圆角文本框 -->
<link href="<%=request.getContextPath() %>/fare/css/htc/htc.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
$(function(){
	$("#choose9").click(function(){
		var va =$("#choose9").attr("checked");
		if(va=="checked"){
			$("[name='grabChannel_chb']").attr("checked",'true');
		}else{
			   $("[name='grabChannel_chb']").removeAttr("checked");
		}
		 /* $("input[name='grabChannel_chb']").each(function(){
			var value = $(this).parent().attr('name');
			if(value == "00003 " || 
					value=="00004 "||
					value=="00001 "||
					value=="00002 "||
					value=="20000 "||
					value=="20001 "||
					value=="20004 "||
					value=="20005 "||
					value=="20006 "||
					value=="20003 "||
					value=="20002 "||
					value=="20007 "){
				$(this).attr("checked","checked");
			}
		 }); */
	});
	
	$("#isReturn").bind('change',function(){
		var isRet =$("#isReturn").val();
		if(isRet==0){
			$("#date_return").hide();
			$("#date_simple").show();
		}else{
			$("#date_return").show();
			$("#date_simple").hide();
		}
	});
});


</script>
<script type="text/javascript">
function showm(sid){
var which = document.getElementById("lite" + sid);
var imgmenu = document.getElementById("ling" + sid);
	if (which.style.display == "none"){
		document.getElementById("lite" + sid).style.display="";
	}
	else{
		document.getElementById("lite" + sid).style.display="none";
		}

}
function currentDate(){ 
    var now = new Date();       
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
   
    var today = year + "-";       
    if(month < 10)
        today += "0";       
    today += month + "-";       
    if(day < 10)
        today += "0";           
    today += day;       
    return(today); 
}

function jumpTo(){
	window.location.href = "taskInfoAction!addTaskInfo.action";
}

function delRow(trId){
	$("#"+trId).remove();
}
function addRow(trId){
	var type=trId.split("_");
	var id = type[0];
	var num="";
	for(var i=0;i<6;i++){
		num+=Math.floor(Math.random()*10);
	}
	if(id=="dateAndFrequence"){
		var rowNum = id+"_"+num;
		$("#simple_table").append('<TR id="dateAndFrequence_0">'+
				'<TD style="text-align: center; width: 25%" class="left">航班日期范围：</TD>'+
				'<TD style="text-align: left" class="left" colspan="3">'+
				'<span>未来 </span> '+
				'<input  type="text" onchange="chekcformDateNumber()" maxlength="3" style="width: 40px" id="formDateNumber" value="${taskInfoVO.grabsopeBegin }" name="formDateNumber"> '+
				'<span>到</span> <input type="text" onchange="chekcformtoDateNumber()" maxlength="3" style="width: 40px" id="toDateNumber" value="${taskInfoVO.grabsopeEnd }" name="toDateNumber">'+ 
				'<span>天的航班</span> '+
				'<span style="color: #ff0000">*请填入范围（0~360）的值</span>'+
				'<span>每</span>'+ 
			    '<input type="text" style="width: 40px" onchange="checkfrequency()" maxlength="4" id="frequency" value="${taskInfoVO.frequency}" name="frequency"> '+
				'<span>小时抓取一次</span>'+	
				'<span style="color: #ff0000">*</span>'	+
				'<input type="button" onclick="javascript:addRow(\''+rowNum+'\');"value="添加"/>'+
				'<input type="button" onclick="javascript:delRow(\''+rowNum+'\');" value="删除"/>'+
				'</TD></TR>');
			
	}
	if(id=="returnDate"){
		var returnId="returnDate_"+num;
		var roundDay="assignRoundDay_"+num;
		var assignFlightDay="assignFlightDay_"+num;
		var frequency="frequency_"+num;
		$("#return_table").append('<TR id="'+returnId+'">'+
				'<td style="text-align: center; width: 25%" class="left">航班日期：</td>'+
				'<TD style="text-align: left" class="left" colspan="3">'+
				'<span>第</span> <input type="text"  style="width: 40px" id="'+assignFlightDay+'" name="assignFlightDay">'+
				'<span>天的航班</span><input type="text" style="width: 40px"  maxlength="4" id="'+roundDay+'" name="assignRoundDay"> '+
				'<span>后返回</span>'+
				'<input type="button" onclick="javascript:addRow(\''+returnId+'\');" value="添加"/>'+
				'<input type="button" onclick="javascript:delRow(\''+returnId+'\');" value="删除"/>'+
				'</TR>');
		
	}
	
}
function addRowByData(grabBeginDate,grabEndDate,frequence){
	var fromVal = $("#dateAndFrequence_0").find("#formDateNumber").val();
	var toVal = $("#dateAndFrequence_0").find("#toDateNumber").val();
	if(grabBeginDate != fromVal && grabEndDate != toVal){
		if(grabBeginDate!=''&&grabEndDate!=''){
			var id = "dateAndFrequence_";
			var rowNum = $(".form_table tr").size()+1;
			var trClone = $("#dateAndFrequence_0").clone();
			$(trClone).attr("id",id+rowNum);
			$("#dateAndFrequence_0").after($(trClone));
		/* 	var trId = '"#'+$(trClone).attr("id")+'"'; */
		    $(trClone).find("#formDateNumber").val(grabBeginDate);
		    $(trClone).find("#toDateNumber").val(grabEndDate);
		    $(trClone).find("#frequency").val(frequence);
		    
		}
	}
	

}

function ajaxSubmit(){
	var data= $("#taskForm").serialize();
	var url="<%=request.getContextPath() %>"+"/taskInfoAction!editTaskInfo.action";
	 $.ajax({
			url:url,
			type : "POST",
			cache : false, 
			data: data,
			async : true,
		    dataType:'html',
		    success:function(data){
	    		if(data=='OK'){
	    		 alert("保存成功！")
	    		 parent.gridManager.loadData();
	   			 parent._dialog.close();
	    		}
	    		
		    },
		    error:function(){ 
		    	alert("请先登录");
		    },
	 });
}
</script>

<script type="text/javascript">
	$(document).ready(function(){
		if("${act}"!="update"){//非更新状态下让其可以选择城市
			$('#fromCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList,changeDoFusion: changeEvent});
			$('#toCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList,changeDoFusion: changeEvent});
		}
		
	});
	$(document).ready(function(){
		$('#fromCity2').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
		$('#toCity2').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	});
	function loadAndDisplayData(grid,url){
		if('${depCity}'!=''&&'${arrCity}'!=''){
			$.ajax({
		        url : url,
		        data:{
		        	depCity:"${depCity}",
		        	arrCity:"${arrCity}",
		        	beginDateAfterToday:"${beginDateAfterToday}",
		        	endDateAfterToday:"${endDateAfterToday}",
		        	channels:"${channels}",   
		        	priceType:"${priceType}",
		        	grapDate:"${grapDate}",
		        	bookingType:"${bookingType}"
		        	},
		        cache : false, 
		        async : false,
		        type : "POST",
		       	complete: function(jqXHR, textStatus){
		       		if(jqXHR.status==200){
		       			result = parseObj(jqXHR.responseText)
		       			var data = result.json;
			        	var xml = result.xml;
			        	grid.ligerGrid({
			                height:'284px',
			                columns:columns,
			                data:data,
			                pageSize:10,
			                rownumbers:true
			            });
			        	$('#text').val(xml);
			        	setChart();
		       		}
		       	}
		    });
		}
	}

	var columns = [
		
	               ];
	$(function(){
		var grid = $("#maingrid");
		loadAndDisplayData(grid,'lowestPriceTrendAction!analyse.action');
		
		grid.ligerGrid({
	        height:'200px',
	        columns:columns
	    });
		var columns = [{ display: '抓取渠道', name: 'channel', align: 'center', width: 440, minWidth: 60 } ];
		registPicker('channels',"pageUtilAction!channels.action",columns,460,'channel');
		$('#depCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
		$('#arrCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
		$('#grapDate').val(currentDate());
		
		var msg="${mes}";
	    if(msg != "" && msg != null && msg != "a"){
			alert(msg);
		}
	})
	
	
function changeAction(url){
	$('#channel').attr('action',url);
}

</script>


<script type="text/javascript">
	//保存抓取航空设置提交
	function checkForm() {
      
		
		var myAct=$("#myAct").val();//表单提交动作  update=="更新"  其他为保存动作
		
		if(myAct=="update"){
			if ($("#grabChannel").val() == '') {
				alert("网站名称不能为空！");
				$("#grabChannel").focus();
				return false;
			}
		}else{//多选
			var len=$("input[name='grabChannel_chb']:checked").length;
			if(len==0){
				alert("请至少选择一个网站");
				return false;
			}
			
		}
		
		 var tocity = $("#toCity").val();
		 var formcity = $("#fromCity").val();
		// alert(tocity+formcity);
		 if(tocity ==''||formcity==''||tocity=='中文/拼音'||formcity=='中文/拼音'){
			 alert("航段设置不能为空，请选择！");
			 $("#fromCity").focus();
			 return false;
		 }
		 if(formcity == tocity){
			 alert("出发地与目的地不能相同，请重新选择！");
			 $("#fromCity").focus();
			 return false;
		 }
		 
		 
		 	var fromValue = '';
		 	var toValue = '';
		 	var frequenceValue = '';
			if ($("#isReturn").val() == '1') {
				
				var re =new RegExp("^[0-9]*[1-9][0-9]*$");
				var isOK =true;
			    $("input[name=assignFlightDay]").each(function(){
			    	  if($.trim($(this).val()) == ''){
			    		  
			    		  $(this).val("");
						  $(this).focus();
						  alert("第几天出发的时间不能为空!");
						  isOK=false;
			    		  return false;
			    		 
			    	  }else if(isNaN($(this).val())){
			    		  
						  $(this).focus();
			    		  alert("第几天出发的时间只能为数字!");
			    		  isOK=false;
			    		  return false;
			    	  }else  if($(this).val().match(re) == null){
							
							$(this).focus();
							alert("第几天出发的时间,请输入正整数值");
							isOK=false;
				    	    return false;
						}
				      fromValue += $(this).val()+';';  	
				});
			    if(!isOK){
			    	return false;
			    }
			    
			    $("input[name=assignRoundDay]").each(function(){
			    	  if($.trim($(this).val()) == ''){
			    		 
			    		  $(this).val("");
						  $(this).focus();
			    		  alert("多少天后回来时间不能为空!");
			    		  isOK=false;
			    		  return false;
			    	  }else if(isNaN($(this).val())){
			    		  
						  $(this).focus();
			    		  alert("多少天后回来时间只能为数字!");
			    		  isOK=false;
			    		  return false;
			    	  }else  if($(this).val().match(re) == null){
							
							$(this).focus();
							alert("多少天后回来时间,请输入正整数值");
							isOK=false;
				    		  return false;
						}
			    	  toValue += $(this).val()+';';  	
					});
				    if(!isOK){
				    	return false;
				    }
				    var frequency = $("#frequency_0").val();
					 if(frequency == ''){
						 alert('抓取频率不能为空！');
						 $("#frequency_0").focus();
							return false;
					 }
					 if(frequency <= 0 || frequency > 99 || isNaN(frequency)){
						 alert('抓取频率必须在0到99之间的数字！');
						 $("#frequency_0").focus();
							return false;
					 }
					 if(frequency.indexOf('.') > 0){
						 var array = frequency.split(".");
						 if(array[1].length > 1){
							 alert('抓取频率最多允许输入1位小数！');
							 $("#frequency_0").focus();
								return false;
						 }
					 }
					 frequenceValue=  frequency + ';';
				
			}else{
					if ($("#formDateNumber").val() == '') {
						alert("航班日期范围不能为空！");
						$("#formDateNumber").focus();
						return false;
					}
					var formDateNumber = $("#formDateNumber").val();
					var reg1 = new RegExp("^\\d+$"); 
					if(formDateNumber.match(reg1) == null){
						alert("请正确填写航班日期范围");
						$("#formDateNumber").focus();
						return false;
					}
					
					if ($("#toDateNumber").val() == '') {
						alert("航班日期范围不能为空！");
						$("#toDateNumber").focus();
						return false;
					}
					var toDateNumber = $("#toDateNumber").val();
					var reg1 = new RegExp("^\\d+$"); 
					if(toDateNumber.match(reg1) == null){
						alert("请正确填写航班日期范围");
						$("#toDateNumber").focus();
						return false;
					}
					if(formDateNumber > toDateNumber){
						alert("航班日期范围开始时间必须小于或等于结束时间");
						$("#formDateNumber").focus();
						return false;
					}
					var frequency = $("#frequency").val();
					 if(frequency == ''){
						 alert('抓取频率不能为空！');
						 $("#frequency").focus();
							return false;
					 }
					 if(frequency <= 0 || frequency > 99 || isNaN(frequency)){
						 alert('抓取频率必须在0到99之间的数字！');
						 $("#frequency").focus();
							return false;
					 }
					 if(frequency.indexOf('.') > 0){
						 var array = frequency.split(".");
						 if(array[1].length > 1){
							 alert('抓取频率最多允许输入1位小数！');
							 $("#frequency").focus();
								return false;
						 }
					 }
					 
					    $("input[name=formDateNumber]").each(function(){
						      fromValue += $(this).val()+';';  	
						});
					    $("input[name=toDateNumber]").each(function(){
					    	toValue += $(this).val()+';';  	
						});
					    $("input[name=frequency]").each(function(){
					    	frequenceValue += $(this).val()+';';  	
						});
					    
					 
			}
		
			 $("#fromDateNumberString").val(fromValue);
			 $("#toDateNumberString").val(toValue);
			 $("#frequenceString").val(frequenceValue);
	
		
		
		
		
		if ($("#validityFromStr").val() == ''
				|| $("#validityFromStr").val() == null) {
			alert("抓取时间段不能为空！");
			$("#validityFromStr").focus();
			return false;
		}
		if ($("#validityToStr").val() == ''
				|| $("#validityToStr").val() == null) {
			alert("抓取时间段不能为空！");
			$("#validityToStr").focus();
			return false;
		}
			
	
		
		var priority = $("#priority").val();
		 if(priority == ''){
			 alert("抓取权重不能为空！");
				$("#priority").focus();
				return false;
		 }
		 
		var reg = new RegExp("^\\d+$"); 
		if(priority.match(reg) == null || priority>1001 || priority <0){
			alert("抓取权重必须为0到1000之间的整数");
			$("#priority").focus();
			return false;
		}

		
		
		var len=$("input[name='grabChannel_chb']:checked").length;
		if(len>=1){
			var webName=new Array();
			var i=0;
			$("input[name='grabChannel'][type='hidden']").val("");//清空
			$("input[name='grabChannel_chb']:checked").each(function(){
				webName[i]=($(this).val().split(","))[2];
				var self=this;
				var oldStr=$("input[name='grabChannel'][type='hidden']").val();
				if(oldStr!="" && len>1){
					oldStr+=";";//分割符号
				}
				$("input[name='grabChannel'][type='hidden']").val(oldStr+$(self).val());
				i++;
			});
			var flag=confirm("您所选择的网站有\n\n"+webName.join("\n")+"\n\n是否继续保存？");
			if(!flag){
				return false;
			}
		}
		
		$("#grabChannel").attr('disabled',false);
		var flag = "${isUpdate}";
		if(flag!='yes'){
			if(checkTask(formcity,tocity)){
		 		//alert("dd");
				//$("#taskForm").submit();
				ajaxSubmit();
			}else{
				//alert("该航线已经存在,请重新填写!");
				return false;
			} 
		}else{
			//$("#taskForm").submit();
			ajaxSubmit();
		}
	 	
		
	}
    
	function checkTask(fromcity,tocity){
		var grabChannel = '';
		$("input[name='grabChannel_chb']:checked").each(function(){
			grabChannel +=($(this).val().split(","))[1]+";";
			
		});
		/* //alert(grabChannel+" adfadfasd ");     
		 $.ajax("taskInfoAction!checkTaskInfoEntity.action", 
				 { "fromCity":fromcity,"toCity":tocity,"grabChannel":grabChannel},
				   function(data){
					 alert(data);
					 if(data && data=='OK'){
						 return true;
					 }else{
						 ///alert(data[0].shortName);
						 
						 var str = '';
						 var jsondata = data;
						 for(var x in jsondata){
						     str+=jsondata[x].shortName+' ';
						 }
						 alert(fromcity+"-"+tocity+"下"+"\n  "+str+"\n"+"已经配置");
						 return false;
					 }
			   }, "text"); */
		var flag = false;
		 $.ajax({
			   type:"POST",
			   url: "taskInfoAction!checkTaskInfoEntity.action",
			   async:false,
			   dataType:"json",
			   data:{ "fromCity":fromcity,"toCity":tocity,"grabChannel":grabChannel},
			   success: function(data){
				 var jsonData = data;
				 if(jsonData && jsonData[0].shortName == 'OK'){
					
					 flag = true;
				 }else{
					 ///alert(data[0].shortName);
					//alert("sdfasdfadsf");
					 var str = '';
					 var jsondata = data;
					 for(var x in jsondata){
					     str+=jsondata[x].shortName+' ';
					 }
					 alert(fromcity+"-"+tocity+"航线在"+"\n  "+str+"\n"+"网站已经配置, 请重新选择");
					 return false;
				 }
		   }
			 });
		 return flag;
	}
	
	
	function showTaskInfoList() {
		
		 var tocity2 = $("#toCity2").val();
		 var formcity2 = $("#fromCity2").val();
		 
		 /* if(tocity2 ==''||formcity2==''||tocity2=='中文/拼音'||formcity2=='中文/拼音'){
			 alert("航段设置不能为空，请选择！");
			 $("#fromCity2").focus();
			 return false;
		 } */
		 
		 /* if(tocity ==''||formcity==''||tocity2=='中文/拼音'||formcity2=='中文/拼音'){
			 alert("航段设置不能为空，请选择！");
			 $("#fromCity").focus();
			 return false;
		 } */
		 
		 if((formcity2 == tocity2)&(tocity2 !='中文/拼音')&(formcity2 !='中文/拼音')){
			 alert("出发地与目的地不能相同，请重新选择！");
			 $("#fromCity2").focus();
			 return false;
		 }
		
		var formDateNumber2=$.trim($("#formDateNumber2").val());
		var toDateNumber2=$.trim($("#toDateNumber2").val());
		
		if(formDateNumber2==""){
			//alert("航班日期范围不能为空！");
			$("#formDateNumber2").val("");
			//return false;
		}
		
		if(isNaN(formDateNumber2)){
			alert("航班日期范围只能为数字！");
			$("#formDateNumber2").val("");
			$("#formDateNumber2").focus();
			return false;
		}
		
		if(toDateNumber2==""){
			//alert("航班日期不能为空！");
			$("#toDateNumber2").val("");
			//return false;
		}
		if(isNaN($("#toDateNumber2").val())){
			alert("航班日期范围只能为数字！");
			$("#toDateNumber2").val("");
			$("#toDateNumber2").focus();
			return false;
		}
		
		
		$("#showTaskInfoListForm").submit();
	}
	
	//分页查询
	function searchOnSubmit(e) {
		var pageSize = $("#pageSize").val();
		var pageNum = $("#pageNum").val();
		if(e!=undefined){//表示是pageSize触发了变化
			//pageNum="1";//在pageSize变化的情况下需要把页码重置到第一页
			$("#pageNum").val("1");//pageNum重置为1
		}
		$("#showTaskInfoListForm").submit();//提交表单
	} 
	
	// 导出订单
	function emp() {
		var grabChannel2 = $("#grabChannel2H").val();
		var fromCity = $("#fromCityH").val();
		var toCity = $("#toCityH").val();
		var formDateNumberStrs = $("#formDateNumberStrsH").val();
		var toDateNumberStrs = $("#toDateNumberStrsH").val();
		var str = 'grabChannel2H='+grabChannel2+'&fromCityH='+fromCity+'&toCityH='+toCity
				 +'&formDateNumberStrsH='+formDateNumberStrs+'&toDateNumberStrsH='+toDateNumberStrs;
		$("#showTaskInfoListForm").attr("action","taskInfoAction!exculTaskInfo.action?"+str).submit();
	}

	// 导入订单
	function imp() {
		if($("#fileText").val() == "" || $("#fileText").val() == null){
			alert("请选择需要导入的Excel文件！");
			return false;
		}else{
			$("#showTaskInfoListForm").attr("action","taskInfoAction!impExculTaskInfo.action?imageFileName="+$("#fileText").val()).submit();
		}
	}
	
	 //商家全选
    function allCheckbox(id){ //用id区分  
		var tform=document.forms['showTaskInfoListForm'];  
		for(var i=0;i<tform.length;i++){  
			var e=tform.elements[i];  
			if(e.type=="checkbox" && e.name==id) e.checked=!e.checked;  
		}  
	 } 
	 
	 function allDeleteTaskInfo(){
		 
		 if(confirm('确定要删除吗？')){
			 $("#showTaskInfoListForm").attr("action","taskInfoAction!deleteTaskInfoEntity.action").submit();
		 }
	 }
	 
	 
	 function currentDate(){ 
		    var now = new Date();       
		    var year = now.getFullYear();
		    var month = now.getMonth() + 1;
		    var day = now.getDate();
		   
		    var today = year + "-";       
		    if(month < 10)
		        today += "0";       
		    today += month + "-";       
		    if(day < 10)
		        today += "0";           
		    today += day;       
		    return(today); 
		} 
	 
	 
	 
	 $(function(){
	 
		//==============================================================================================================xiaoken start
		//不要经常用onblur失去焦点来判断玩之后弹出框又让焦点回去，某种情况下会造成死循环
		if("${isUpdate}"!="yes"){//非更新情况下默认为当前时间，一定要加这个条件，不然下面代码冲突，大哥谁写的代码啊！！！
			$("#validityFromStr").val(currentDate());
			$("#validityToStr").val("2099-12-31");
		}else{//更新状态下出发到达城市只读
			$("#fromCity").attr("readonly",true);
			$("#toCity").attr("readonly",true);
			//是否抓去往返  1==是  0==否
			$("#isReturn").val($.trim(${taskInfoVO.isReturn}));
			if($("#isReturn").val()=="0"){
				$("#returnDateScope").val("");//在不抓取往返天数的情况下，请置空
			}else if($("#isReturn").val()=="1"){
				$("#date_return").show();
				$("#date_simple").hide();
				var assignList =${assignList};
				if(assignList.assignList!=null && assignList!="false"){
					var assignId="";
					$.each(assignList.assignList,function(idx,e){
						if(assignId==""){
							assignId+=e.id;
						}else{
							assignId+=','+e.id;
						}
						if(idx==0){
							$("#assignFlightDay_0").val(e.assignFlightDay);
							$("#assignRoundDay_0").val(e.assignRoundDay);
							$("#frequency_0").val($.trim(${taskInfoVO.frequency}));
						}else{
							var returnId="returnDate_"+e.id;
							var roundDay="assignRoundDay_"+e.id;
							var assignFlightDay="assignFlightDay_"+e.id;
							var frequency="frequency_"+e.id;
							$("#return_table").append('<TR id="'+returnId+'">'+
									'<td style="text-align: center; width: 25%" class="left">航班日期：</td>'+
									'<TD style="text-align: left" class="left" colspan="3">'+
									'<span>第</span> <input type="text"  style="width: 40px" id="'+assignFlightDay+'" name="assignFlightDay" value="'+e.assignFlightDay+'">'+
									'<span>天的航班</span><input type="text" style="width: 40px"  maxlength="4" id="'+roundDay+'" name="assignRoundDay" value="'+e.assignRoundDay+'"> '+
									'<span>后返回</span>'+
									'<input type="button" onclick="javascript:addRow(\''+returnId+'\');" value="添加"/>'+
									'<input type="button" onclick="javascript:delRow(\''+returnId+'\');" value="删除"/>'+
									'</TR>');
							
							
						}
					});
					$("#assign_Id").val(assignId);
				}
			}
			//回填权重
			$("#priority").val(${taskInfoVO.priority});
		}
		//选择是否抓取
		$("#isReturn").change(function(){
			if($(this).val()=="0"){
				$("#returnDateScope").val("");//在不抓取往返天数的情况下，请置空
			}
		});
		//测试	
		//==============================================================================================================xiaoken end
		  
		 var channel = "${taskInfoVO.grabChannel}";
		 if(channel == ''){
			 $("#grabChannel").find("option").each(function(){
				 var val = $(this).val();
				 if(val.indexOf('南方航空') > 0){
					 $(this).attr("selected","selected");
				 }
			 });
		 }
		 
		 var status = "${status}";
		
		 if(status == "taskInfonotfound" ){
			 alert("查无数据，请重新选择查询条件");
		 }
		 
		 
		 var flag = "${isUpdate}";
		 var idString ="${taskInfoVO.idString}";
		 var grabBegin = "${taskInfoVO.grabBegin}";
		 var grabEnd = "${taskInfoVO.grabEnd}";
	     var frequenceString = "${taskInfoVO.frequenceString}";
		 var beginArr = grabBegin.split(",");
		 var endArr = grabEnd.split(",");
		 var frequenceArr = frequenceString.split(",");
		 for(var i=0;i<beginArr.length;i++){
			 addRowByData(beginArr[i],endArr[i],frequenceArr[i]);
		 }
		 
		 if(flag=='yes'){
			 
			 
			 var tocity = $("#toCity").val();
			 var fromcity = $("#fromCity").val();
			
			 findExistCompanyByLine(fromcity,tocity);
			 //禁止修改出发地、目的地
			 $("#fromCity").attr("disabled","disabled");
			 $("#toCity").attr("disabled","disabled");
			 $("#hfromCity").val($("#fromCity").val());
			 $("#htoCity").val($("#toCity").val());
			 
		 }	
		 
	 });
	 
	 
	 function chekcformDateNumber(){
		 
		 	
			var reg = new RegExp("^\\d+$"); 
			var value = $("#formDateNumber").val();
		 if (value == '') {
			alert("航班日期范围不能为空！");
			$("#formDateNumber").focus();
			return false;
		}		
		 
		 
		if(value < 0 || value > 360 || value.match(reg) == null){
			 alert('请填写0到360之间的数字！');
			 $("#formDateNumber").val("");
			 $("#formDateNumber").focus();
				return false;
		}
		
		
		
		/* if(value.match(reg) == null){
			alert("请正确填写航班日期范围");
			$("#formDateNumber").val("");
			$("#formDateNumber").focus();
			return false;
		} */
		
	 }
	 
	 function chekcformtoDateNumber(){
		var value2 = $("#toDateNumber").val();
		var reg = new RegExp("^\\d+$"); 
		if (value2 == '') {
			alert("航班日期范围不能为空！");
			
			$("#toDateNumber").focus();
			return false;
		}
		 
		/* if(value.match(reg) == null){
			alert("请正确填写航班日期范围");
			$("#toDateNumber").val("");
			$("#toDateNumber").focus();
			return false;
		} */		
		
		if((value2 < 0) || (value2 > 360) || (value2.match(reg) == null)){
			 alert('请填写0到360之间的数字！');
			  $("#toDateNumber").val("");
			 $("#toDateNumber").focus();
				return false;
		}
		
		var fordate =  $("#formDateNumber").val();
		if(fordate > value2){
			alert("航班日期范围开始时间必须小于或等于结束时间");
			$("#toDateNumber").val("");
			$("#formDateNumber").focus();
			return false;
		}
		
	 }
	 
	 function chekctoDateNumber2(){

		 
		 var value = $("#formDateNumber2").val();
		 	
			var reg = new RegExp("^\\d+$"); 
		/*  if (value == '') {
			alert("航班日期范围不能为空！");
			$("#formDateNumber2").focus();
			return false;
		} */		
		if(value != "" && (value < 0 || value > 360 || value.match(reg) == null)){
			 alert('请填写0到360之间的数字！');
			 $("#formDateNumber2").val("");
			 $("#formDateNumber2").focus();
				return false;
		}
	 }
	 
	 function chekcformtoDateNumber2(){
			var value2 = $("#toDateNumber2").val();
			
			var reg = new RegExp("^\\d+$"); 
			/* if (value2 == '') {
				alert("航班日期范围不能为空！");
				$("#toDateNumber2").focus();
				return false;
			} */
			 
			/* if(value.match(reg) == null){
				alert("请正确填写航班日期范围");
				$("#toDateNumber").val("");
				$("#toDateNumber").focus();
				return false;
			} */		
			
			if(value2 != "" && (value2 < 0 || value2 > 360 || value2.match(reg) == null)){
				 alert('请填写0到360之间的数字！');
				  $("#toDateNumber2").val("");
				 $("#toDateNumber2").focus();
					return false;
			}
			
			var fordate =  $("#formDateNumber2").val();
			if(fordate > value2){
				alert("航班日期范围开始时间必须小于或等于结束时间");
				$("#toDateNumber2").val("");
				$("#formDateNumber2").focus();
				return false;
			}
			
		 }
	 
	 
	 function checkfrequency(){
		 var frequency = $("#frequency").val();
		 if(frequency == ''){
			 alert('抓取频率不能为空！');
			 $("#frequency").focus();
				return false;
		 }
		 if(frequency <= 0 || frequency > 99 || isNaN(frequency)){
			 alert('抓取频率必须在0到99之间的数字！');
			 $("#frequency").val("");
			 $("#frequency").focus();
				return false;
		 }
		 if(frequency.indexOf('.') > 0){
			 var array = frequency.split(".");
			 //alert(array[1]);
			 if(array[1].length > 1){
				 alert('抓取频率最多允许输入1位小数！');
				  $("#frequency").val("");
				 $("#frequency").focus();
					return false;
			 }
		 }
		 
	 }
	 
	 function checkpriority(){
		 var priority = $("#priority").val();
		 if(priority == ''){
			 alert("抓取权重不能为空！");
				$("#priority").focus();
				return false;
		 }
		 
		var reg = new RegExp("^\\d+$"); 
		if(priority.match(reg) == null || priority>1000 || priority <0){
			alert("抓取权重必须为0到1000之间的整数");
			$("#priority").val("");
			$("#priority").focus();
			return false;
		}
			
	 }
	 
	 //异步获得航线存在的航空公司
	 function changeEvent(){
		 //alert("daaaaa");
		 var tocity = $("#toCity").val();
		 var fromcity = $("#fromCity").val();
		 
		 if((fromcity =='' && tocity !='')||(tocity=='中文/拼音'&& fromcity=='中文/拼音')){
			 alert("航段设置不能为空，请选择！");
			 $("#fromCity").focus();
			 return false;
		 }else if(fromcity == tocity){
			 alert("出发地与目的地不能相同，请重新选择！");
			 $("#fromCity").focus();
			 return false;
		 }else if((fromcity !='' && tocity== '')||fromcity !='' && tocity== '中文/拼音'){
			 return false;
		 }else{
			 findExistCompanyByLine(fromcity,tocity);
			 
		 }
	
		
	 }
	 
function findExistCompanyByLine(fromcity,tocity){
	$.post("taskInfoAction!findExistCompanyByLine.action", 
			 { "fromCity":fromcity,"toCity": tocity},
			   function(data){
				 var jsonarray = data;
				 $('input[name="grabChannel_chb"]').each(function(){  
					 $(this).parent().show();

				 }); 		 
				 //获得所有checkbox的值,将不符合的checkbox隐藏
				 $('input[name="grabChannel_chb"]').each(function(){  
					 var hbaseKey = $(this).val().split(",")[1];
					 for(var i =0;i<jsonarray.length;i++){
						 if(jsonarray[i].hbaseKey == hbaseKey){
							break;
						}else if((i+1) == jsonarray.length){	
					        $(this).parent().hide();
						}	 
				     }

				 }); 
		   }, "json");
	
	
} 
	 
	 
</script>

</head>

<body>
	<form id="taskForm" action="taskInfoAction!editTaskInfo.action" method="post">
	<input type="hidden" value="${fromCity}" id="hfromCity" name="hfromCity"/>
	<input type="hidden" value="${toCity }" id="htoCity" name="htoCity"/>
	<input type="hidden" value="${formDateNumber }" id="hformDateNumber" name="hformDateNumber"/>
	<input type="hidden" value="${toDateNumber }" id="htoDateNumber" name="htoDateNumber"/>
	<input type="hidden" value="${grabChannel2 }" id="hgrabChannel2" name="grabChannel2"/>
	<!-- 一个用于标明本次页面跳转的动作元素 -->
	<input type="hidden" value="${act}" id="myAct" name="act"/>
	<!-- 在新增的时候用来存放字符串的 -->
	 <s:if test="act!='update'">
	 	<input type="hidden" value="" name="grabChannel"/>
	 </s:if>
		<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 class="form_table">
			<TBODY>
				<input type="hidden" name="taskId"  id ="taskId"  value="${taskInfoVO.id }" />
				<tr>
					<TD style="text-align: center;width: 25%" class="left" >航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;段：</TD>
					<TD style="text-align: left" class="left" colspan="5">
						<div >
							<span>从 </span> 
							<!-- <s:if test="act!='update'">id='fromCity'</s:if> -->
							<!-- <s:if test="act=='update'">readonly=true </s:if> -->
							<input  id="fromCity" name="fromCity" type='text' value='${taskInfoVO.fromCityName }' style="width: 100px" /> 
							<span>到</span> 
							<input onchange="checktoCity()" id="toCity"  name="toCity" type='text' value='${taskInfoVO.toCityName }' style="width: 100px" />
							<span style="color: #ff0000">*</span><br />
						</div>
					</TD>
					
				</tr>
				
				<TR >
					<TD style="text-align: center" class="left">网站名称：<br/><input type="checkbox"  id="choose9" value="1"></input>(全选)</TD>
					<TD style="text-align: center" class="left" colspan="5">
					
						<%--  <s:if test="act=='update'">
							<select class="easyui-combobox" name="grabChannel" style="width: 150px;"  id="grabChannel"    <s:if test="act=='update'">disabled="disabled"</s:if>>
								<c:choose>
									<c:when test="${sourceVOList == null}">
									</c:when>
									<c:otherwise>
										<c:forEach var="item" items="${sourceVOList }">
											<option value="${item.idAndHbaseKeyAndName}"      <c:if test="${item.name==taskInfoVO.grabChannel }">selected='selected'</c:if>>${item.name}</option>
										</c:forEach>
									</c:otherwise>
								</c:choose>
							</select> 
							<span style="color: #ff0000">*</span>
						</s:if> --%>
						
						
						<!-- 多选网站的模块，如果是修改的情况下保持原来的不变，新增下会出现此模块 -->
						<%--  <s:if test="act!='update'"> --%>
						    <s:if test="act!=''">
						 
						 
							<c:choose>
								<c:when test="${sourceVOList == null}">
									暂无网站数据
								</c:when>
								<c:otherwise>
								<table  id="allWeb_table" >
									

							 		
						 			<c:forEach var="item" items="${sourceVOList }" varStatus="status">
						 				<c:if test="${status.first}" >
						 					<tr>
						 				</c:if>
						 					<td name='${item.hbaseKey} '>
							 					<input  type="checkbox" id="${status.index}" name="grabChannel_chb" value="${item.idAndHbaseKeyAndName}"
							 						<c:if test="${grabChannelId == item.id}">checked="checked"</c:if>
							 						<c:if test="${act=='update'}">disabled="disabled"</c:if>
							 					>
							 						</input> 
							 					<!--  
							 					<label for="${status.index}">${item.name}</label> 
							 					-->${item.shortName}
							 					
							 				</td>
						 					
						 				<c:if test="${(status.index+1)%10==0 && !status.first}">
						 					</tr>
						 				</c:if>
						 				<c:if test="${(status.index+1)%10==0 && !status.last && !status.first}">
						 					<tr>
						 				</c:if>
						 			</c:forEach>
						 			
								</table>
								</c:otherwise>
							</c:choose>
					
						</s:if>
					</TD>
				</TR>
				<tr>
					<TD style="text-align: center" class="left">抓取时间段：</TD>
					<TD style="text-align: left" class="left" colspan="3">
						<span>从 </span> 
						
						<input type="text" style="width: 100px" id="validityFromStr"   
							value="<fmt:formatDate pattern='yyyy-MM-dd' value='${taskInfoVO.validityFrom}'/>"
							name="validityFromStr"
							onClick="WdatePicker({maxDate:'#F{$dp.$D(\'validityToStr\')||\'2099-12-31\'}'})"/> 
						
							
						<span>到</span> 
						<input type="text" style="width: 100px" id="validityToStr" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${taskInfoVO.validityTo}" />" name="validityToStr" 
						onClick="WdatePicker({minDate:'#F{$dp.$D(\'validityFromStr\')}',maxDate:'2099-12-31'})"> 
						<span style="color: #ff0000">*</span>
					</TD>
				</tr>
				
				<%-- <TR >
					
					<TD style="text-align: center" class="left">抓取频率：</TD>
					<TD style="text-align: left" class="left" colspan="3">
						<span>每</span> 
						<input type="text" style="width: 40px" onchange="checkfrequency()" maxlength="4" id="frequency" value="${taskInfoVO.frequency}" name="frequency"> 
						<span>小时抓取一次</span>
						<span style="color: #ff0000">*</span>
					</TD>
				</TR> --%>
			    <TR class="tab">
				<TD style="text-align: center" class="left">是否抓取往返数据：</TD>
					<TD style="text-align: left" class="left">
						<!--  <!--<c:if test="${taskInfoVO.isReturn=='0 '||taskInfoVO.isReturn=='0'}"> selected='selected'</c:if> -->
						<select id="isReturn" name="isReturn">
						<option value="0">否</option>
						<option value="1">是</option>
						</select>
					</TD>
				</tr>
				<tr>
				<td style="text-align: center" class="left">抓取优先级: </td>
				<TD style="text-align: left" class="left" colspan="5">
				<input type="text" style="width: 40px" onchange="checkpriority()" id="priority" name="priority" value="0"/> <!-- 默认0 -->
				
				<span style="color: #ff0000">*抓取权重优先+1，默认为0，封顶1000，值越大的抓取的优先权越高</span>
				</TD>
				</tr>
					</TBODY>
			</TABLE>
				<div id="date_simple" >
				<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 class="form_table" id="simple_table">
					<TBODY>
						<TR id="dateAndFrequence_0">
							
							<TD style="text-align: center; width: 25%" class="left">航班日期范围：</TD>
							<TD style="text-align: left" class="left" colspan="3">
								<span>未来 </span> 
								<input  type="text" onchange="chekcformDateNumber()" maxlength="3" style="width: 40px" id="formDateNumber" value="${taskInfoVO.grabsopeBegin }" name="formDateNumber"> 
								<span>到</span> <input type="text" onchange="chekcformtoDateNumber()" maxlength="3" style="width: 40px" id="toDateNumber" value="${taskInfoVO.grabsopeEnd }" name="toDateNumber"> 
								<span>天的航班</span> 
								<span style="color: #ff0000">*请填入范围（0~360）的值</span>
								<span>每</span> 
								<input type="text" style="width: 40px" onchange="checkfrequency()" maxlength="4" id="frequency" value="${taskInfoVO.frequency}" name="frequency"> 
								<span>小时抓取一次</span>
								<span style="color: #ff0000">*</span>
								<input type="button" onclick="javascript:addRow('dateAndFrequence_0');"value="添加"/>
								<b></b>
							</TD>
						</TR>
					</TBODY>
					</TABLE>
				</div>
				<div id="date_return" style="display: none;" >
					<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 class="form_table" id="return_table">
						<TBODY>
							<TR id="returnDate_0">
							<td style="text-align: center; width: 25%" class="left">航班日期：</td>
							<TD style="text-align: left" class="left" colspan="3">
							<span>第</span> <input type="text"  style="width: 40px" id="assignFlightDay_0" name="assignFlightDay">
							<span>天的航班</span> <input type="text" style="width: 40px"  maxlength="4" id="assignRoundDay_0" name="assignRoundDay"> 
							<span>后返回</span>
							<input type="text" style="width: 40px"  maxlength="4" id="frequency_0" >  
							<span>小时抓取一次</span>
							<span style="color: #ff0000">*</span>
							<input type="button" onclick="javascript:addRow('returnDate_0');" value="添加"/>
						</TR>
						</TBODY>
					</TABLE>
				</div>
			
				<TR >
					<!-- <TD style="text-align: center" class="left">
						
					</TD> -->
					<td colspan="6" style="text-align: center;height: 35px">
						<input type="button" class="btn05" name="Submit222" id="Submit222" 
						onclick="javascript:checkForm();">
						<input type="reset" class="btn02"value="" name="Submit222" id="Submit222" 
						onclick="">
						<!-- <input type="button" class="btn16" name="Submit222" id="Submit222" 
						onclick="javascript:jumpTo();"> -->
					</td>
				</TR>
				<tr> 
					
				</tr>
				<input type="text" value="" id="fromDateNumberString" name="fromDateNumberString" style="display: none;"/>
				<input type="text" value="" id="toDateNumberString" name="toDateNumberString" style="display: none;"/>
				<input type="text" value="" id="frequenceString" name="frequenceString" style="display: none;"/>
				<input type="text" value="${grabChannelId}" id="grabChannelId" name="grabChannelId" style="display: none;"/>
				<input type="text" value="${idAndGrapScope}" id="idAndGrapScope" name="idAndGrapScope" style="display: none;"/>
				<input type="hidden" name="assignId" id="assign_Id"/>
	</form>

	<p></p>
    
	
</body>
</html>

